<div on:mouseenter="show()" on:mouseleave="hide()" class="help">
    <span>{#if visible}<i class="im im-graduation-hat"></i>{:else}?{/if}</span>
    {#if visible}
    <div class="content">
        <slot />
    </div>
    {/if}
</div>

<style type="text/css">
    .help {
        float: right;
        position: relative;
        z-index: 8000;
    }

    .help .content::after {
        content: '';
        position: absolute;
        top: 8px;
        right: 8px;
    }

    .help .content {
        display: block;
    }

    .help .content {
        /*display: none;*/
        position: absolute;
        top: -8px;
        right: -8px;
        padding: 8px 40px 8px 10px;
        background: #18a1cd;
        color: #fff;
        width: 260px;
        border-radius: 2px;
        box-shadow: 3px 2px 2px rgba(0, 0, 0, 0.1);
        z-index: 8000;
    }

    .help .content img {
        max-width: none;
    }

    .help > span {
        font-family: Roboto;
        z-index: 100001;
        font-weight: 400;
        position: relative;
        display: block;
        width: 22px;
        height: 22px;
        line-height: 22px;
        border-radius: 50%;
        background: transparent;
        text-align: center;
        color: #6c6e6f66;
        font-size: 16px;
        top: -2px;
    }

    .help:hover > span {
        background: #18a1cd;
        color: #f9f9f9;
    }
    .help > span .im {
        font-size: 16px;
        color: #fff;
    }
</style>

<script>
    export default {
        data() {
            return {
                visible: false
            };
        },
        methods: {
            show() {
                const t = setTimeout(() => {
                    this.set({ visible: true });
                }, 400);
                this.set({ t });
            },
            hide() {
                const { t } = this.get();
                clearTimeout(t);
                this.set({ visible: false });
            }
        }
    };
</script>
